
	async function handleUploadFile(url,filePath,fileType,keyName,header,formData) {
		console.log(url)
		
		return new Promise(async (resovle,reject)=>{
			
			// #ifdef H5
				if(filePath.startsWith('blob:'))
				{
					console.log(filePath)
					
					const file = await new Promise((resovle,reject)=>{
						var xhr = new XMLHttpRequest()
						xhr.responseType = "blob";  

						xhr.onload = () => {  
							// 获取返回结果  
							var blob = xhr.response;  
							var ext = blob.type.split('/').pop();
							console.log(ext)
							var file = new File([blob], 'filename.'+ext, {type: blob.type})
							console.log(file)
							resovle(file)
						}
						console.log(filePath)
						xhr.open('GET',filePath)
						xhr.send(null);
					})
					
					console.log(file)
					
					uni.uploadFile({
						url: url,
						name:keyName,
						file,
						header,
						formData,
						success: (uploadFileRes) => {
							console.log(uploadFileRes)
							resovle(JSON.parse(uploadFileRes.data))
							//resovle(uploadFileRes)
							console.log(uploadFileRes, '上传成功')
						},
						fail: (res) => {
							reject(res.errMsg)
							console.log(res, '上传失败')
						}
					})
					
					return
				}
			// #endif
			
			uni.uploadFile({
				url: url,
				name:keyName,
				fileType,
				filePath,
				header,
				formData,
				success: (uploadFileRes) => {
					console.log(uploadFileRes)
					resovle(JSON.parse(uploadFileRes.data))
					//resovle(uploadFileRes)
					console.log(uploadFileRes, '上传成功')
				},
				fail: (res) => {
					reject(res.errMsg)
					console.log(res, '上传失败')
				}
			})
		})
	}

export default { 
	handleUploadFile
}